<style>
input[type="text"]{
	width: 200px!important;
}
</style>
<div class="form">
<?php $form = $this->beginWidget('GxActiveForm', array(
	'id' => 'bill-model-form',
	'enableAjaxValidation' => false,
));
?>

	<p class="note">
		<?php echo Yii::t('app', 'Fields with'); ?> <span class="required">*</span> <?php echo Yii::t('app', 'are required'); ?>.
	</p>

	<?php echo $form->errorSummary($model); ?>
		<table width ="100%">
			<tr>
				<td valign="top">
					
					<div class="row">
					<?php echo $form->labelEx($model,'created_datetime'); ?>
					<?php echo $form->error($model,'created_datetime'); ?>
					<?php 
					$this->widget('zii.widgets.jui.CJuiDatePicker',
							array(
									// you must specify name or model/attribute
									//'model'=>$model,
									//'attribute'=>'projectDateStart',
									'name'=>'BackendBillModel[created_datetime]',
					
									// optional: what's the initial value/date?
									//'value' => $model->projectDateStart
									'value' => empty($model->created_datetime)?date('d/m/Y'):date('d/m/Y', strtotime($model->created_datetime)),
					
									// optional: change the language
									'language' => 'en',
									//'language' => 'fr',
									//'language' => 'es',
					
									/* optional: change visual
									 * themeUrl: "where the themes for this widget are located?"
					* theme: theme name. Note that there must be a folder under themeUrl with the theme name
					* cssFile: specifies the css file name under the theme folder. You may specify a
					*          single filename or an array of filenames
					* try http://jqueryui.com/themeroller/
					*/
									'themeUrl' => Yii::app()->baseUrl.'/css/jui' ,
									'theme'=>'pool',	//try 'bee' also to see the changes
									'cssFile'=>array('jquery-ui.css' /*,anotherfile.css, etc.css*/),
					
					
									//  optional: jquery Datepicker options
									'options' => array(
											// how to change the input format? see http://docs.jquery.com/UI/Datepicker/formatDate
											'dateFormat'=>'dd/mm/yy',
					
											// user will be able to change month and year
											'changeMonth' => 'true',
											'changeYear' => 'true',
					
											// shows the button panel under the calendar (buttons like "today" and "done")
											'showButtonPanel' => 'true',
					
											// this is useful to allow only valid chars in the input field, according to dateFormat
											'constrainInput' => 'false',
					
											// speed at which the datepicker appears, time in ms or "slow", "normal" or "fast"
											'duration'=>'fast',
					
											// animation effect, see http://docs.jquery.com/UI/Effects
											'showAnim' =>'slide',
									),
					
					
									// optional: html options will affect the input element, not the datepicker widget itself
									'htmlOptions'=>array(
											'style'=>'height:30px;
			background:#ffbf00;
			color:#00a;
			font-weight:bold;
			font-size:0.9em;
			border: 1px solid #A80;
			padding-left: 4px;'
									)
							)
					);
					?>
					</div><!-- row -->
					<div class="row">
					<?php echo $form->labelEx($model,'am_bill'); ?>
					<?php echo $form->textField($model, 'am_bill', array('maxlength' => 255)); ?>
					<?php echo $form->error($model,'am_bill'); ?>
					</div><!-- row -->
				</td>
				<td valign="top">
					<div class="row">
						<?php 
						echo $form->radioButtonList($model, 'code', array(0=>"Trong nước", 1=>"Quốc tế"), array('separator'=>" ", 'labelOptions'=>array('style'=>'display: inline'), "class"=>'type_cpn'));
						?>
					</div>
					<div class="row">
					<?php echo $form->labelEx($model,'type'); ?>
					<?php 
						$data = array(
								'AM'=>'AM',
								'DHL'=>'DHL',
								'FEDEX'=>'FEDEX',
								'TNT'=>'TNT'
						);
						echo $form->dropDownList($model, 'type',  $data, array("id"=>"type_bill"));
					?>
					<?php echo $form->error($model,'type'); ?>
					</div><!-- row -->
					<div class="row">
					<?php echo $form->labelEx($model,'air_bill'); ?>
					<?php 
					if($model->type!='AM' && !$model->isNewRecord){
						echo $form->textField($model, 'air_bill', array('maxlength' => 255));
					}else{
						echo $form->textField($model, 'air_bill', array('disabled' => 'disabled'));
					}
					?>
					<?php echo $form->error($model,'air_bill'); ?>
					</div><!-- row -->
				</td>
				<td valign="top">
					<div class="row">
					<?php echo $form->labelEx($model,'customer_name'); ?>
					<?php echo $form->textField($model, 'customer_name', array('maxlength' => 255)); ?>
					<?php echo $form->error($model,'customer_name'); ?>
					</div><!-- row -->
					<div class="row">
					<?php echo $form->labelEx($model,'receiver'); ?>
					<?php echo $form->textField($model, 'receiver', array('maxlength' => 255)); ?>
					<?php echo $form->error($model,'receiver'); ?>
					</div><!-- row -->
				</td>
				<td valign="top">
					<div class="row">
					<?php echo $form->labelEx($model,'customer_address'); ?>
					<?php echo $form->textArea($model, 'customer_address', array('style'=>'width: 400px;height: 25px;')); ?>
					<?php echo $form->error($model,'customer_address'); ?>
					</div><!-- row -->
					<div class="row">
					<?php echo $form->labelEx($model,'receiver_address'); ?>
					<?php echo $form->textArea($model, 'receiver_address', array('style'=>'width: 400px;height: 25px;')); ?>
					<?php echo $form->error($model,'receiver_address'); ?>
					</div><!-- row -->
				</td>
			</tr>
		</table>
		<table width="100%">
			<tr>
				<td>
					<div class="row">
					<?php echo $form->labelEx($model,'description'); ?>
					<?php echo $form->textArea($model, 'description', array('style'=>'width: 400px;height: 25px;')); ?>
					<?php echo $form->error($model,'description'); ?>
					</div><!-- row -->
				</td>
				<td>
					<div class="row">
					<?php echo $form->labelEx($model,'product_weight'); ?>
					<?php echo $form->textField($model, 'product_weight'); ?>
					<?php echo $form->error($model,'product_weight'); ?>
					</div><!-- row -->
				</td>
				<td>
					<div class="row">
					<?php echo $form->labelEx($model,'fee'); ?>
					<?php echo $form->textField($model, 'fee', array('maxlength' => 100)); ?>
					<?php echo $form->error($model,'fee'); ?>
					</div><!-- row -->
				</td>
			</tr>
		</table>
		
<?php
echo GxHtml::submitButton(Yii::t('app', 'Save'),array('class'=>'btn btn-success'));
$this->endWidget();
?>
</div><!-- form -->
<script>
$(".type_cpn").live("click", function(){
	var type = $(this).val();
	$.ajax({
		url: "index.php?r=bill/bill/getTypeCpn&type="+type,
		success: function(response){
			$("#type_bill").html(response);
			if(type!=0){
				$("#BackendBillModel_air_bill").removeAttr("disabled");
			}else{
				$("#BackendBillModel_air_bill").attr("disabled","disabled");
			}
		}
	})
})
</script>